package com.jvtd.nettyim.im.serialize;

import com.jvtd.nettyim.im.serialize.impl.JSONSerializer;

/**
 * @author Created by neal.zhang
 * @date 2020/5/27 - 20:07
 */
public interface Serializer {

    Serializer DEFAULT = new JSONSerializer();

    /**
     * 获取序列化算法
     *
     * @return
     */
    byte getSerializerAlgorithm();

    /**
     * java对象转二进制
     *
     * @param obj
     * @return
     */
    byte[] serialize(Object obj);

    /**
     * 反序列化
     *
     * @param clazz
     * @param bytes
     * @param <T>
     * @return
     */
    <T> T deserialize(Class<T> clazz, byte[] bytes);

}
